<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <style>
        ul li {
            list-style: none;
            background-color: aquamarine;
            border-radius: 5px;
            color: white;
            float: left;
            padding: 20px;
            margin: 10px;
        }
        .isclass{
            background-color: tomato;
            font-size: 20px;
        }
    </style>
    <div id="app">
        <ul v-for=" (item,index) in hobby" :class="{isclass}">
            <li @click="getcheck(index)">
                {{item.name}}
            </li>
        </ul><br><br>
        选中更改样式
        <ul v-for=" item in hobby" v-if="item.name">
            <li @click="getcheck(index)">
                {{item.name}}
            </li>
        </ul>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                hobby: [
                    { "name": "游戏", show: false },
                    { "name": "代码", show: true },
                    { "name": "看书", show: false },
                    { "name": "打牌", show: true },
                    { "name": "游泳", show: false }
                ]
            },
             methods: {
                getcheck(index) {
                    this.hobby[index].show= !this.hobby[index].show
                }
            }
        })
    </script>
</body>

</html>